/**
 * 初始化页面
 */
function initPage() {
    getModuleOperationByUserDMAndModuleDM(parent.parent.session.USER_DM, myTools.getQueryString("MODULE_DM"), '1', "securityDIV");
    //取模块权限按钮
    getUser();
}
/**
 *取得用户列表
 */
function getUser() {
    var json = {
        url:contextPath + "/server/base/select.do",
        msg:"数据加载中.....",
        form:"searchForm",
        params:{
            "SQLID":"user.selectUser"
        },
        callback:[getUserCallBack]
    };
    AjaxTools.ajax(json);
}
/**
 * 翻页
 * @param page
 * @return
 */
function queryPage(page) {
    var json = {
        url:contextPath + "/server/base/select.do",
        msg:"数据加载中.....",
        form:"searchForm",
        params:{
            "SQLID":"user.selectUser",
            "CURPAGE":page
        },
        callback:[getUserCallBack]
    };
    AjaxTools.ajax(json);
}
function getUserCallBack(json) {
    if (json.code == "00") {
        var a = {
            priKey:"USER_DM",
            header:["用户帐号","用户名称","用户描述"],
            column:["ACCOUNT","USER_NAME","USER_DESC"],
            aligns:["center","left","left"],
            width:[60,90,],
            data:json,
            pageFun:"queryPage"
        };
        myGrid.grid(a);
    } else {
        alert(json.data);
    }
}
/**
 *显示添加用户窗口
 */
function addUser() {
    win.open('addUser', '添加用户', '../../../admin/user/addUser.jsp', 550, 250, true, true);
}
/**
 *显示修改用户窗口
 */
function editUser() {
    var id = myGrid.getSelectedID();
    if (id)
        win.open('editUser', '修改用户', '../../../admin/user/editUser.jsp?USER_DM=' + id, 450, 250, true, true);
}

/**
 *显示分配角色窗口
 */
function addUserRole() {
    var id = myGrid.getSelectedID();
    if (id)
        win.open('addUserRole', '分配角色', '../../../admin/user/addUserRole.jsp?USER_DM=' + id, 450, 250, true, true);
}
/**
 * 删除用户
 */
function delUser() {
    var ids = myGrid.getSelectedIDS();
    if (ids) {
        if (confirm("是否确认删除？")) {
            var json = {
                url:contextPath + "/server/sys/deleteUser.do",
                msg:"数据删除中.....",
                params:{
                    "IDS":ids
                },
                callback:[delUserCallBack]
            };
            AjaxTools.ajax(json);
        }
    }
}
function delUserCallBack(json) {
    var code = json.code;
    if (code == "00") {
        alert(json.data);
        getUser();
    } else {
        alert(json.data);
    }

}
function changePWD() {
    var id = myGrid.getSelectedID();
    if (id) {
        if (confirm("密码将被重置为000000，是否继续？")) {
            var json = {
                url:contextPath + "/server/sys/insertUserPwd.do",
                msg:"数据保存中.....",
                params:{
                    "USER_DM":id,
                    "USER_PWD":"000000"
                },
                callback:[changePWDCallBack]
            };
            AjaxTools.ajax(json);
        }
    }
}
function changePWDCallBack(json) {
    var code = json.code;
    if (code == "00") {
        alert("密码重置成功！");
    } else {
        alert(json.data);
    }
}